package com.niiwoo.civet.mobile.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSON;
import com.niiwoo.civet.mobile.vo.request.user.UserForbidQueryRequestVO;
import com.niiwoo.civet.user.enums.UserForbidTypeEnum;
import com.niiwoo.civet.user.service.UserForbidDubboService;
import com.niiwoo.tripod.web.util.PrincipalContext;
import com.niiwoo.tripod.web.vo.Empty;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * Created by wuke on 2017/10/12
 */
@Slf4j
@RestController
@RequestMapping("/userBehavior")
@Api(tags = "用户行为禁止", description = "/userBehavior")
public class UserBehaviorController {
    @Reference(version = "1.0.0")
    private UserForbidDubboService userForbidDubboService;

    @PostMapping("/userBehaviorListQuery")
    @ApiOperation("用户行为禁止查询")
    public Empty userForbidQuery(@RequestBody @Valid UserForbidQueryRequestVO requestVO) {
        String userId = PrincipalContext.getUserId();
        log.info("userForbidQuery.userId={},requestVO={}",userId, JSON.toJSONString(requestVO));
        userForbidDubboService.validUserForbidInfo(userId, UserForbidTypeEnum.enumOf(requestVO.getForbidType()));
        log.info("userForbidQuery.userId={} end",userId);
        return Empty.getInstance();
    }
}
